package br.usp.pcs.basys2.file;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import br.usp.pcs.basys2.info.FileInfo;

public class FileManager {
	
	private Map<String,BasysFile> filesMap = new HashMap<String, BasysFile>();

	public BasysFile get(String filename) {
		return filesMap.get(filename);
	}

	public BasysFile put(String fileName, BasysFile file) {
		return filesMap.put(fileName, file);
	}
	
	public void setFiles(List<FileInfo> fileInfoList) {
		for (FileInfo info : fileInfoList) {
			this.put(info.getName(),new BasysFile(info));
		}
	}

	public void addListenerToFiles(FileManagerListener e) {
		Collection<BasysFile> values = filesMap.values();
		for (BasysFile p : values) {
			p.add(e);
		}
	}
}
